public class Test {
    public static void main(String[] args) {
        TestBinaryTree testBinaryTree = new TestBinaryTree();
        // 根据一棵树的后序遍历与中序遍历构造二叉树
        char[] postOrder = {'H','I','D','E','B','J','F','G','C','A'};
        char[] inOrder = {'H','D','I','B','E','A','J','F','C','G'};
        TestBinaryTree.TreeNode root = testBinaryTree.buildTree2(inOrder,postOrder);

        System.out.print("前序遍历：");
        testBinaryTree.preOrder(root);
        System.out.println();

        System.out.print("中序遍历：");
        testBinaryTree.inOrder(root);
        System.out.println();

        System.out.print("后序遍历：");
        testBinaryTree.postOrder(root);
        System.out.println();

        System.out.println("结点数：" + testBinaryTree.size(root));
        System.out.println("叶子数：" + testBinaryTree.getLeafNodeCount(root));
        System.out.println("第k层的结点数：" + testBinaryTree.getKLevelNodeCount(root,3));
        System.out.println("二叉树的高度：" + testBinaryTree.getHeight(root));

        System.out.println(testBinaryTree.find(root, 'G').val);

        System.out.println("层序遍历：");
        testBinaryTree.levelOrder(root);
        System.out.println();

        System.out.println("是否是完全二叉树：" + testBinaryTree.isCompleteTree(root));

        System.out.print("非递归前序遍历1：");
        testBinaryTree.preOrderNor(root);
        System.out.print("非递归前序遍历2：");
        testBinaryTree.preOrderNor1(root);
        System.out.print("非递归中序遍历：");
        testBinaryTree.inOrderNor(root);
        System.out.print("非递归后序遍历：");
        testBinaryTree.postOrderNor(root);

    }

    public static void main3(String[] args) {
        TestBinaryTree testBinaryTree = new TestBinaryTree();
        // 根据一棵树的前序遍历与中序遍历构造二叉树
        char[] preOrder = {'A','B','D','H','I','E','C','F','G'};
        char[] inOrder = {'H','D','I','B','E','A','F','C','G'};
        TestBinaryTree.TreeNode root = testBinaryTree.buildTree1(preOrder,inOrder);

        System.out.print("前序遍历：");
        testBinaryTree.preOrder(root);
        System.out.println();

        System.out.print("中序遍历：");
        testBinaryTree.inOrder(root);
        System.out.println();

        System.out.print("后序遍历：");
        testBinaryTree.postOrder(root);
        System.out.println();

        System.out.println("结点数：" + testBinaryTree.size(root));
        System.out.println("叶子数：" + testBinaryTree.getLeafNodeCount(root));
        System.out.println("第k层的结点数：" + testBinaryTree.getKLevelNodeCount(root,3));
        System.out.println("二叉树的高度：" + testBinaryTree.getHeight(root));

        System.out.println(testBinaryTree.find(root, 'G').val);

        System.out.println("层序遍历：");
        testBinaryTree.levelOrder(root);
        System.out.println();

        System.out.println("是否是完全二叉树：" + testBinaryTree.isCompleteTree(root));

    }
    public static void main2(String[] args) {
        TestBinaryTree testBinaryTree = new TestBinaryTree();
        // 根据前序遍历序列 创建二叉树
        TestBinaryTree.TreeNode root = testBinaryTree.createTree("ABC##DE#G##F###");

        System.out.print("前序遍历：");
        testBinaryTree.preOrder(root);
        System.out.println();

        System.out.print("中序遍历：");
        testBinaryTree.inOrder(root);
        System.out.println();

        System.out.print("后序遍历：");
        testBinaryTree.postOrder(root);
        System.out.println();

        System.out.println("结点数：" + testBinaryTree.size(root));
        System.out.println("叶子数：" + testBinaryTree.getLeafNodeCount(root));
        System.out.println("第k层的结点数：" + testBinaryTree.getKLevelNodeCount(root,4));
        System.out.println("二叉树的高度：" + testBinaryTree.getHeight(root));

        System.out.println(testBinaryTree.find(root, 'G').val);

        System.out.println("层序遍历：");
        testBinaryTree.levelOrder(root);
        System.out.println();

        System.out.println("是否是完全二叉树：" + testBinaryTree.isCompleteTree(root));
    }
    public static void main1(String[] args) {
        TestBinaryTree testBinaryTree = new TestBinaryTree();
        testBinaryTree.create();//创建二叉树

        System.out.print("前序遍历：");
        testBinaryTree.preOrder(testBinaryTree.root);
        System.out.println();

        System.out.print("中序遍历：");
        testBinaryTree.inOrder(testBinaryTree.root);
        System.out.println();

        System.out.print("后序遍历：");
        testBinaryTree.postOrder(testBinaryTree.root);
        System.out.println();

        System.out.println("结点数：" + testBinaryTree.size(testBinaryTree.root));
        System.out.println("叶子数：" + testBinaryTree.getLeafNodeCount(testBinaryTree.root));
        System.out.println("第k层的结点数：" + testBinaryTree.getKLevelNodeCount(testBinaryTree.root,4));
        System.out.println("二叉树的高度：" + testBinaryTree.getHeight(testBinaryTree.root));

        System.out.println(testBinaryTree.find(testBinaryTree.root, 'G').val);

        System.out.println("层序遍历：");
        testBinaryTree.levelOrder(testBinaryTree.root);
        System.out.println();

        System.out.println("是否是完全二叉树：" + testBinaryTree.isCompleteTree(testBinaryTree.root));
    }
}
